package com.softoa.contorller;

import com.softoa.pojo.User;
import com.softoa.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
@CrossOrigin
public class UserController {

    @Autowired
    IUserService userService;

    @RequestMapping("login")
    public User login(User user){
        User u = userService.userSelectOne(user);
        if(u==null)return null;
        if(u.getUserPassword().equals(user.getUserPassword())){
            return u;
        }
        return null;
    }

    @RequestMapping("createTask")
    public List<User> createTask(){return userService.userSelectList(); }

    @RequestMapping("/list")
    public List<User> showList(){
        return userService.userSelectList();
    }

    @RequestMapping("selectone")
    public User selectOne(User user){return userService.userSelectOne(user); }
}
